<%--
  Created by IntelliJ IDEA.
  User: 星星在唱歌
  Date: 2022/2/25
  Time: 8:56
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<html>
<head>
    <title>旅游管理系统</title>
    <link rel="stylesheet" href="${pageContext.request.contextPath}/static/bootstarp/bootstrap.css">
    <script src="${pageContext.request.contextPath}/static/bootstarp/bootstrap.js"></script>
    <script src="${pageContext.request.contextPath}/static/js/jquery-3.4.1.js"></script>
</head>
<style>
    a{
        text-decoration: none;
        color: hotpink;
        font-width: 7;
    }
</style>
<body>
<div style="margin: 0 auto;text-align: center" class="container">
    <h1 style="text-align: center">旅游景点信息列表</h1>
    <span><a href="${pageContext.request.contextPath}/page/register.jsp">添加景点信息</a></span><br><br>
    <form action="${pageContext.request.contextPath}/main?cmd=main" method="post" name="form1" class="form-inline">
        <div class="form-group">
        <input type="hidden" name="p" id="p">
            <label for="">城市</label>
        <select name="cityID" id="" class="form-control input-sm">
            <option value="">==全部==</option>
            <c:forEach items="${city}" var="c">
                <option value="${c.cityId}" <c:if test="${condition.cityID == c.cityId}">selected</c:if>> ${c.cityName} </option>
            </c:forEach>
        </select>
            <label for="">价格区间：</label>
            <input type="text" name="" id="" class="form-control input-sm" placeholder="请输入最小金额" value="${condition.min}">
            <input type="text" name="" id="" class="form-control input-sm" placeholder="请输入最大金额" value="${condition.max}">
        </div>
        <input type="submit" value="查询" class="btn btn-primary input-sm">
    </form>
    <table class="table table-striped table-hover">
        <thead>
            <tr>
                <td>景点编号</td>
                <td>景点介绍</td>
                <td>发布时间</td>
                <td>票价</td>
                <td>城市名称</td>
                <td>删除</td>
                <td>详细</td>
                <td>修改</td>
            </tr>
        </thead>
        <c:forEach items="${pb.dataList}" var="list">
            <tr>
                <td>${list.id}</td>
                <td>${list.introduce}</td>
                <td>${list.pubTime}</td>
                <td>${list.price}</td>
                <td>${list.cityName}</td>
                <td><a href="javascript:del(${list.id})" class="btn btn-danger">删除</a></td>
                <td><a href="javascript:full(${list.id})" class="btn btn-success">详细</a></td>
                <td><a href="javascript:upd(${list.id})" class="btn btn-info">修改</a></td>
            </tr>
        </c:forEach>

        <tr>
            <td colspan="8" style="text-align: center">
                <a href="javascript:toPage(1)">首页</a>&nbsp;&nbsp;
                <a href="javascript:toPage(${pb.p-1})">上一页</a>&nbsp;&nbsp;
                <a href="javascript:toPage(${pb.p+1})">下一页</a>&nbsp;&nbsp;
                <a href="javascript:toPage(${pb.pageCount})">末页</a> &nbsp; &nbsp;&nbsp;
                <span style="font-style: italic;font-weight: bolder">
                    ${pb.p}&nbsp;~
                    ${pb.pageCount}
                </span>
            </td>
        </tr>
    </table><br>
</div>
<script>
    function toPage(p){
        $("#p").val(p);
        document.form1.submit();
    }

    function del(id){
        if (confirm("是否删除")){
            window.location.href = "${pageContext.request.contextPath}/main?cmd=del&id="+id;
        }
    }
    function full(id){
            window.location.href = "${pageContext.request.contextPath}/main?cmd=full&id="+id;
    }
    function upd(id){
            window.location.href = "${pageContext.request.contextPath}/main?cmd=upd&id="+id;
    }
    <c:if test="${del == 'ok'}">
    alert("删除成功！")
    </c:if>
    <c:if test="${del == 'no'}">
    alert("删除失败！")
    </c:if>
    <c:if test="${register == 'ok'}">
    alert("添加成功！")
    </c:if>
    <c:if test="${register == 'no'}">
    alert("添加失败！")
    </c:if>
    <c:if test="${upd == 'ok'}">
    alert("修改成功！")
    </c:if>
    <c:if test="${upd == 'no'}">
    alert("修改失败！")
    </c:if>
</script>

</body>
</html>
